package okhttp;

import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;

import java.io.IOException;

/**
 * 官方Demo
 * http://square.github.io/okhttp
 * Created by Niki on 2018/10/26 17:00
 */
public class OfficialDemo {
    private static String officialDemo1(String url) throws IOException {
        OkHttpClient client = new OkHttpClient();

        Request request = new Request.Builder()
                .url(url)
                .build();

        Response response = client.newCall(request).execute();

        return response.body().string();
    }

    public static void main(String[] args) {
        try {
            String content = officialDemo1("http://www.baidu.com");
            System.out.println(content);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
